// ex9_1:golf.cpp
#include <iostream>
#include "golf.h"
#include <cstring>

//const int Len = 40;

/*struct golf
{
    char fullname[Len];
    int handicap;
};*/

// non-interactive version:
// function sets golf structure to provided name, handicap
// using values passed as arguments to the function
void setgolf(golf &g, const char *name, int hc)
{
	strncpy(g.fullname, name, strlen(name));
	g.handicap   = hc;
}

// interactive version
// function solicits name and handicap from user
// and sets the members of g to the values entered
// returns 1 if name is entered, 0 if name is empty string
int setgolf(golf &g)
{
	if (strlen(g.fullname) == 0)
	{	strncpy(g.fullname, "",strlen(""));
		std::cout << g.fullname << "\n";
		g.handicap = 0;
		return 0; 
	}
	else
	{	
		std::cout << g.fullname << "\n";
		return 1;
	}
		
}

// function resets handicap to new value
void handicap(golf &g, int hc)
{
	g.handicap = hc;
}

// function displays contents of golf structure
void showgolf(const golf &g)
{
	if (strlen(g.fullname) > 0)
	{
		std::cout << g.fullname << " "
			<< g.handicap << "\n";
	}
	else
		std::cout << "None" << " "
			<< 0 << "\n";
}
//#endif
